/*
 * Created on Mar 6, 2005
 *
 */

package clustering.implementations;
import clustering.framework.*;
import java.io.*;
/**
 * @author Tudor.Ionescu@supelec.fr

NCDistance

This class is an implementation of the normalized compression distance. See section 2.1.? for details. This distance is applicable on files which have been compressed using one of the implementations of the ICompressor interface, excepting the NULLCompressor class. 

 */
public class NCDistance implements IDistanceMetric{
	long max(long a, long b){
		if(a>b)return a;
		return b;
	}
	long min(long a, long b){
		if(a<b)return a;
		return b;
	}
	public double Compute(File f_compX, File f_compY, File f_compXY)throws Exception{
	    long x = f_compX.length();
	    long y = f_compY.length();
	    long xy = f_compXY.length();
		return ((double)xy - (double)min(x,y))/(double)max(x,y); 
	}
}
